import { ChargeDao } from "../pay_server/dao/ChargeDao";
import { Config } from "../src/config/Config";
import DateUtil from "../src/engine/utils/DateUtil";
import { Logger } from "../src/engine/utils/Logger";


const checkClearClubHistory_Inteval: number = 1000 * 60 * 60 * 24;//1天检查一次

export class LogClearManager {

    public static instance: LogClearManager = new LogClearManager();

    private last_check_club_time: number = 0

    public checkClear(now: number) {
        this.checkClearClubHistory(now)
    }

    private checkClearClubHistory(now: number) {
        if (now - this.last_check_club_time >= checkClearClubHistory_Inteval) {
            let date: Date = new Date()
            if (date.getHours() == 5) { //你见过半夜5点的篮球吗？
                this.last_check_club_time = now;
                // let delete_time: number = now - Config.OneDay * 3; //保留3天记录
                let delete_time: number = now - Config.OneDay * 7; //保留7天记录
                Logger.log("LogClearManager===", delete_time, DateUtil.formatDateStr(delete_time))
             
                //定时清理充值垃圾订单
                ChargeDao.clear(delete_time)

               
            }
        }
    }

}